package com.lvmama.pangolin.HBaseOper;

import java.util.HashMap;
import java.util.Map;

import com.lvmama.pangolin.entity.hotel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lvmama.pangolin.common.DateUtil;
import com.lvmama.pangolin.hbaseutil.HBaseUtils;

@Component
public class HotelHBEntityOperation {
	/**  
	* @Title：HBEntityOperation.java
	* @Author:zhoutianqi
	* @Description:
	* @Date：2017年3月7日下午3:52:00  
	*/
	@Autowired
	private HBaseUtils hBaseUtil;
	public boolean saveHotelProduct(HotelPdetail item,String tableName,String family){
		Map<String,String> map = new HashMap<String,String>();
		map.put("id", item.getDetailId());
		map.put("companyCode", item.getCompanyCode());
		map.put("platformCode", item.getPlatformCode());
		map.put("cityCode", item.getCityCode());
		map.put("hotelName", item.getHotelName());
		map.put("hotelAddr", item.getHotelAddr());
		map.put("productId", item.getProductId());
		map.put("comeDate", DateUtil.yyyyMMdd_NOT_.format(item.getComeDate()));
		map.put("leaveDate", DateUtil.yyyyMMdd_NOT_.format(item.getLeaveDate()));
		map.put("lowestPrice", item.getLowestPrice());
		map.put("score", item.getScore());
		map.put("imageNum", item.getImageNum());
		map.put("introduction", item.getIntroduction());
		map.put("saleCount", item.getSaleCount());
		map.put("scoreTag", item.getScoreTag());
		map.put("starLevel", item.getStarLevel());
		map.put("detailUrl", item.getDetailUrl());
		map.put("snapshotAddr", item.getSnapshotAddr());
		map.put("lvProductId", item.getLvProductId());
		map.put("createTime", DateUtil.yyyyMMdd_NOT_.format(item.getCreateTime()));
		map.put("updateTime", DateUtil.yyyyMMdd_NOT_.format(item.getUpdateTime()));
		map.put("taskId", item.getTaskId());
		map.put("taskDate", DateUtil.yyyyMMdd_NOT_.format(item.getTaskDate()));
		map.put("rsrvStr1", item.getRsrvStr1());
		map.put("rsrvStr2", item.getRsrvStr2());
		map.put("rsrvStr3", item.getRsrvStr3());
		map.put("commodityNum", String.valueOf(item.getCommodityNum()));
		map.put("commodityTypeNum", String.valueOf(item.getRoomTypeNum()));
		map.put("commodityPreferentialNum", String.valueOf(item.getPreferentialNum()));
		return hBaseUtil.save(map, tableName, family, item.getDetailId());
	}
	
	public boolean saveHotelProduct(HotelProductDetail item,String tableName,String family){
		Map<String,String> map = new HashMap<String,String>();
		map.put("id", item.getId());
		map.put("companyCode", item.getCompanyCode());
		map.put("platformCode", item.getPlatformCode());
		map.put("cityCode", item.getCityCode());
		map.put("hotelName", item.getHotelName());
		map.put("hotelAddr", item.getHotelAddr());
		map.put("productId", item.getProductId());
		map.put("comeDate", DateUtil.yyyyMMdd_NOT_.format(item.getComeDate()));
		map.put("leaveDate", DateUtil.yyyyMMdd_NOT_.format(item.getLeaveDate()));
		map.put("lowestPrice", item.getLowestPrice());
		map.put("score", item.getScore());
		map.put("imageNum", item.getImageNum());
		map.put("introduction", item.getIntroduction());
		map.put("saleCount", item.getSaleCount());
		map.put("scoreTag", item.getScoreTag());
		map.put("starLevel", item.getStarLevel());
		map.put("detailUrl", item.getDetailUrl());
		map.put("snapshotAddr", item.getSnapshotAddr());
		map.put("lvProductId", item.getLvProductId());
		map.put("createTime", DateUtil.yyyyMMdd_NOT_.format(item.getCreateTime()));
		map.put("updateTime", DateUtil.yyyyMMdd_NOT_.format(item.getUpdateTime()));
		map.put("taskId", item.getTaskId());
		map.put("taskDate", DateUtil.yyyyMMdd_NOT_.format(item.getTaskDate()));
		map.put("isLink", item.getIsLink()+"");
		map.put("rsrvStr2", item.getRsrvStr2());
		map.put("rsrvStr3", item.getRsrvStr3());
		map.put("commodityNum", String.valueOf(item.getCommodityNum()));
		map.put("commodityTypeNum", String.valueOf(item.getCommodityTypeNum()));
		map.put("commodityPreferentialNum", String.valueOf(item.getPreferentialNum()));
		return hBaseUtil.save(map, tableName, family, item.getId());
	}
	
	public boolean saveHotelCommodity(HotelCommodityDetail item,String tableName,String family){
		Map<String,String> map = new HashMap<String,String>();
		map.put("id", item.getId());
//		map.put("roomType", item.getRoomType());
		map.put("roomType", item.getCommodityType());
		map.put("commodityId", item.getCommodityId());
		map.put("area", item.getCityCode());
		map.put("floor", item.getFloor());
		map.put("commodityName", item.getCommodityName());
		map.put("bedType", item.getProductId());
		map.put("broadband", item.getBroadband());
		map.put("breakfast", item.getBreakfast());
		map.put("window", item.getWindow());
		map.put("increaseBed", item.getIncreaseBed());
		map.put("peopleNum", item.getPeopleNum());
		map.put("commodityUrl", item.getCommodityUrl());
		map.put("productId", item.getProductId());
		map.put("cancelRule", item.getCancelRule());
		map.put("preferential", item.getPreferential());
		map.put("salePrice", item.getSalePrice());
		map.put("priceListId", item.getPriceListId());
		map.put("createTime", DateUtil.yyyyMMdd_NOT_.format(item.getCreateTime()));
		map.put("updateTime", DateUtil.yyyyMMdd_NOT_.format(item.getUpdateTime()));
		map.put("taskId", item.getTaskId());
		map.put("taskDate", DateUtil.yyyyMMdd_NOT_.format(item.getTaskDate()));
		map.put("isLink", item.getIsLink()+"");
		map.put("rsrvStr2", item.getRsrvStr2());
		map.put("rsrvStr3", item.getRsrvStr3());
		map.put("companyCode", item.getCompanyCode());
		return hBaseUtil.save(map, tableName, family, item.getId());
	}
	
	public boolean saveHotelCommodity(HotelCdetail item,String tableName,String family){
		Map<String,String> map = new HashMap<String,String>();
		map.put("id", item.getDetailId());
		map.put("roomType", item.getRoomType());
		map.put("commodityId", item.getCommodityId());
		map.put("area", item.getCityCode());
		map.put("floor", item.getFloor());
		map.put("commodityName", item.getCommodityName());
		map.put("bedType", item.getProductId());
		map.put("broadband", item.getBroadband());
		map.put("breakfast", item.getBreakfast());
		map.put("window", item.getWindow());
		map.put("increaseBed", item.getIncreaseBed());
		map.put("peopleNum", item.getPeopleNum());
		map.put("commodityUrl", item.getCommodityUrl());
		map.put("productId", item.getProductId());
		map.put("cancelRule", item.getCancelRule());
		map.put("preferential", item.getPreferential());
		map.put("salePrice", item.getSalePrice());
		map.put("priceListId", item.getPriceListId());
		map.put("createTime", DateUtil.yyyyMMdd_NOT_.format(item.getCreateTime()));
		map.put("updateTime", DateUtil.yyyyMMdd_NOT_.format(item.getUpdateTime()));
		map.put("taskId", item.getTaskId());
		map.put("taskDate", DateUtil.yyyyMMdd_NOT_.format(item.getTaskDate()));
		map.put("rsrvStr1", item.getRsrvStr1());
		map.put("rsrvStr2", item.getRsrvStr2());
		map.put("rsrvStr3", item.getRsrvStr3());
		map.put("companyCode", item.getCompanyCode());
		return hBaseUtil.save(map, tableName, family, item.getDetailId());
	}


	public boolean saveHistoryPrice(HotelPdetail hotelPdetail, HotelCdetail hotelCdetailTtem, String rowkey,String family,String tableName) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("taskId", hotelCdetailTtem.getTaskId());
		map.put("createDate", DateUtil.yyyyMMdd_NOT_.format(hotelCdetailTtem.getCreateTime()));
		map.put("comeDate", DateUtil.yyyyMMdd_NOT_.format(hotelPdetail.getComeDate()));
		map.put("salePrice", hotelCdetailTtem.getSalePrice());
		map.put("companyCode", hotelPdetail.getCompanyCode());
		return hBaseUtil.save(map, tableName, family, rowkey);
	}
	
	public boolean saveHistoryPrice(HotelProductDetail hotelPdetail, HotelCommodityDetail hotelCdetailTtem, String rowkey,String family,String tableName) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("taskId", hotelCdetailTtem.getTaskId());
		map.put("createDate", DateUtil.yyyyMMdd_NOT_.format(hotelCdetailTtem.getCreateTime()));
		map.put("saleDate", DateUtil.yyyyMMdd_NOT_.format(hotelPdetail.getComeDate()));
		map.put("salePrice", hotelCdetailTtem.getSalePrice());
		map.put("companyCode", hotelPdetail.getCompanyCode());
		return hBaseUtil.save(map, tableName, family, rowkey);
	}

	public boolean saveHotelCommodity(HotelCommodityDetailError item, String rowkey, String tableName, String family){
		Map<String,String> map = new HashMap<String,String>();
		map.put("id", item.getId());
		map.put("roomType", item.getRoomType());
		map.put("commodityId", item.getCommodityId());
		map.put("area", item.getCityCode());
		map.put("floor", item.getFloor());
		map.put("commodityName", item.getCommodityName());
		map.put("bedType", item.getProductId());
		map.put("broadband", item.getBroadband());
		map.put("breakfast", item.getBreakfast());
		map.put("window", item.getWindow());
		map.put("increaseBed", item.getIncreaseBed());
		map.put("peopleNum", item.getPeopleNum());
		map.put("commodityUrl", item.getCommodityUrl());
		map.put("productId", item.getProductId());
		map.put("cancelRule", item.getCancelRule());
		map.put("preferential", item.getPreferential());
		map.put("salePrice", item.getSalePrice());
		map.put("priceListId", item.getPriceListId());
		map.put("createTime", DateUtil.yyyyMMdd_NOT_.format(item.getCreateTime()));
		map.put("updateTime", DateUtil.yyyyMMdd_NOT_.format(item.getUpdateTime()));
		map.put("taskId", item.getTaskId());
		map.put("taskDate", DateUtil.yyyyMMdd_NOT_.format(item.getTaskDate()));
		map.put("rsrvStr1", item.getRsrvStr1());
		map.put("rsrvStr2", item.getRsrvStr2());
		map.put("rsrvStr3", item.getRsrvStr3());
		map.put("companyCode", item.getCompanyCode());
		return hBaseUtil.save(map, tableName, family, rowkey);
	}
}
